#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a;i>b;--i)
#define LL long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; LL tmpLONGLONG;

int arr[510][510];
int n;

void show(int x,int y,int direction){
	vector<int>v;
	while(1){
		v.push_back(arr[x][y]);
		++x;--y;
		if(y<0||x>n-1)break;
	}
	if(direction == 1){
		XH(i , 0 , v.size())printf(" %d",v[i]);
	}else{
		XXH(i , v.size()-1 , -1)printf(" %d", v[i]);
	}
}

int main(){
	scanf("%d", &n);
	XH(i , 0 , n){
		XH(j , 0 , n){
			scanf("%d", &arr[i][j]);
		}
	}
	printf("%d",arr[0][0] );
	int direction = 1;
	XH(i , 1 , n){
		show(0,i,direction);
		direction*=-1;
	}
	XH(i , 1 , n){
		show(i,n-1,direction);
		direction*=-1;
	}

	
	return 0;
}